package com.fy.fyzf.presenter;

import com.fy.fyzf.api.SubscriberCallBack;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.AddNoteBean;
import com.fy.fyzf.bean.HousingDetailBean;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.HousingFllowListBean;
import com.fy.fyzf.bean.SearchPassengerBean;
import com.fy.fyzf.view.HouseDetailCallBack;

public class HouseDetailPresenter extends BasePresenter<HouseDetailCallBack> {

    public HouseDetailPresenter(HouseDetailCallBack view) {
        super(view);
    }

    public void getHousingDetail(Integer id){
        addSubscription(mApiService.getHousingDetail(id), new SubscriberCallBack<BaseData<HousingDetailBean>> (mView,true) {
            @Override
            protected void onSuccess(BaseData<HousingDetailBean> response) {
                mView.getHousingDetailSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void addCollectHousing(SearchPassengerBean searchPassengerBean,int position){
        addSubscription(mApiService.addCollectHousing(searchPassengerBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.collectHousingSuccess(response,position);
            }

            @Override
            protected void onError() {

            }
        });
    }


    public void removeCollectionHousing(SearchPassengerBean searchPassengerBean, int position){
        addSubscription(mApiService.removeCollectHousing(searchPassengerBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.removecollectHousingSuccess(response,position);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void editFollow(AddNoteBean addNoteBean) {
        addSubscription(mApiService.addNote(addNoteBean), new SubscriberCallBack<BaseData>(mView,true) {
            @Override
            protected void onSuccess(BaseData response) {
                mView.editFollowSuccess(response);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getHousingFllow(int id){
        addSubscription(mApiService.housingFollow(id), new SubscriberCallBack<BaseData<HousingFllowListBean>>(mView,false) {
            @Override
            protected void onSuccess(BaseData<HousingFllowListBean> response) {
                mView.getHousingFllowListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

}
